package com.czd.support.controller;

import com.czd.base.model.JsonResult;
import com.czd.support.common.Constants;
import com.czd.support.service.DataDictionaryService;
import com.czd.support.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Author: Jerry.hu
 * Create: Jerry.hu (2014-10-11 22:43)
 * Description:
 * To change this template use File | Settings | File Templates.
 */
@Controller
@RequestMapping(value = "/plate")
public class PlateController extends BaseController {

    @Autowired
    private DataDictionaryService dataDictionaryService;
    @Autowired
    private RoomService roomService;

    @RequestMapping(value = {"","/","/list"},method = RequestMethod.GET)
    public String list(Model model){
        model.addAttribute("dataDictionaries",dataDictionaryService.queryRoomCategoryByLevel(Constants.ROOM_CODE));
        return "plate/list";
    }

    @RequestMapping(value = "/{codes}/queryRoom",method = RequestMethod.GET)
    @ResponseBody
    public JsonResult queryRoom(@PathVariable String codes){
        List<Integer> roomIds = roomService.queryForCodes(codes);
        return JsonResult.OK.put("roomIds",roomIds);
    }
}
